package com.ruoyi.web.controller.system;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.Raintestrecord;
import com.ruoyi.system.service.IRaintestrecordService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 雨量计任务Controller
 * 
 * @author ruoyi
 * @date 2024-08-01
 */
@RestController
@RequestMapping("/system/raintestrecord")
public class RaintestrecordController extends BaseController
{
    @Autowired
    private IRaintestrecordService raintestrecordService;

    /**
     * 查询雨量计任务列表
     */
    @PreAuthorize("@ss.hasPermi('system:raintestrecord:list')")
    @GetMapping("/list")
    public TableDataInfo list(Raintestrecord raintestrecord)
    {
        startPage();
        List<Raintestrecord> list = raintestrecordService.selectRaintestrecordList(raintestrecord);
        return getDataTable(list);
    }

    /**
     * 导出雨量计任务列表
     */
    @PreAuthorize("@ss.hasPermi('system:raintestrecord:export')")
    @Log(title = "雨量计任务", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, Raintestrecord raintestrecord)
    {
        List<Raintestrecord> list = raintestrecordService.selectRaintestrecordList(raintestrecord);
        ExcelUtil<Raintestrecord> util = new ExcelUtil<Raintestrecord>(Raintestrecord.class);
        util.exportExcel(response, list, "雨量计任务数据");
    }

    /**
     * 获取雨量计任务详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:raintestrecord:query')")
    @GetMapping(value = "/{RegisterID}")
    public AjaxResult getInfo(@PathVariable("RegisterID") String RegisterID)
    {
        return success(raintestrecordService.selectRaintestrecordByRegisterID(RegisterID));
    }

    /**
     * 新增雨量计任务
     */
    @PreAuthorize("@ss.hasPermi('system:raintestrecord:add')")
    @Log(title = "雨量计任务", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Raintestrecord raintestrecord)
    {
        return toAjax(raintestrecordService.insertRaintestrecord(raintestrecord));
    }

    /**
     * 修改雨量计任务
     */
    @PreAuthorize("@ss.hasPermi('system:raintestrecord:edit')")
    @Log(title = "雨量计任务", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Raintestrecord raintestrecord)
    {
        return toAjax(raintestrecordService.updateRaintestrecord(raintestrecord));
    }

    /**
     * 删除雨量计任务
     */
    @PreAuthorize("@ss.hasPermi('system:raintestrecord:remove')")
    @Log(title = "雨量计任务", businessType = BusinessType.DELETE)
	@DeleteMapping("/{RegisterIDs}")
    public AjaxResult remove(@PathVariable String[] RegisterIDs)
    {
        return toAjax(raintestrecordService.deleteRaintestrecordByRegisterIDs(RegisterIDs));
    }
}
